﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace AirplaneReservation
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogIn_Click(object sender, EventArgs e)
        {
            SqlConnection ccon = new SqlConnection(ConfigurationManager.ConnectionStrings["airplaneConnectionString"].ToString());
            ccon.Open();

            string select = "select * from users where userName='" + txtUser.Text + "' and passW='" + txtPassword.Text + "' ";
            SqlDataAdapter da = new SqlDataAdapter(select, ccon);
            DataTable dt = new DataTable();
            da.Fill(dt);

                int count = dt.Rows.Count;
                if (count == 0)
                {
                    lbError.Text = "Wrong user name or password...";
                }
                else
                {
                    if (dt.Rows[0]["role"].ToString() == "m")
                    {
                        Session["ssRole"] = "member";
                        Response.Redirect("~/Default.aspx");
                    }
                }
            
            ccon.Close();
        }
    }
}